// -*- C++ -*------------------------------------------------------------------
//  $Id: PdbSaver.h,v 1.3 2007-10-26 14:55:17 biocomp Exp $
//
//  Class:              PdbSaver
//
//  Base Class(es):     -
//
//  Derived Class(es):  -
//
//  Containing:         -
//
//  Author:             Silvio Tosatto
//
//  Project Name:       Victor
//
//  Date:               08/99
//
//  Reviewed By:        <Name>
//
//  Description:
//    Saves components (Atoms, Groups, etc.) in standard PDB format.
//
// ---------------------------------------------------------------------------

#ifndef _PDB_SAVER_H_
#define _PDB_SAVER_H_

// Includes:
#include <Group.h>
#include <SideChain.h>
#include <AminoAcid.h>
#include <Spacer.h>
#include <LigandSet.h>
#include <Ligand.h>
#include <Saver.h>
#include <Debug.h>
#include <string>
#include <iostream>

// Global constants, typedefs, etc. (to avoid):

namespace Biopool {

class PdbSaver : public Saver
{
public: 

// CONSTRUCTORS/DESTRUCTOR:
  PdbSaver(ostream& _output = cout) 
    : output(_output), writeSeq(true), writeSecStr(true), writeTer(true), 
      atomOffset(0), aminoOffset(0), ligandOffset(0) { }
  // this class uses the implicit copy operator.
  virtual ~PdbSaver() { PRINT_NAME; }  

// PREDICATES:
    void endFile() { output << "END\n"; }

// MODIFIERS:
  void setWriteSecondaryStructure() { writeSecStr = true; }
  void setDoNotWriteSecondaryStructure() { writeSecStr = false; }

  void setWriteSeqRes() { writeSeq = true; }
  void setDoNotWriteSeqRes() { writeSeq = false; }

  void setWriteAtomOnly() { writeSecStr = false; writeSeq = false; 
                            writeTer = false; }
  void setWriteAll()  { writeSecStr = true; writeSeq = true; 
                        writeTer = true; }

  virtual void saveGroup(Group& gr);
  virtual void saveSideChain(SideChain& sc);
  virtual void saveAminoAcid(AminoAcid& aa);
  virtual void saveSpacer(Spacer& sp);
  virtual void saveLigand(Ligand& l);
  virtual void saveLigandSet(LigandSet& l);

protected:

private:

  // HELPERS:
  void writeSeqRes(Spacer& sp); // writes SEQRES entry
  void writeSecondary(Spacer& sp); 
     // writes secondary entries (SHEET, HELIX, etc.)

  ostream& output;   // output stream
  bool writeSeq, writeSecStr, writeTer;  // write secondary structure?
  unsigned int atomOffset, aminoOffset, ligandOffset;  
  // offsets that determine at which atom, aminoacid and ligand number to start
};

} // namespace
#endif //_PDB_SAVER_H_


